package com.twu.biblioteca.command;

import com.twu.biblioteca.BusinessException;
import com.twu.biblioteca.LibraryController;
import com.twu.biblioteca.model.Title;

public class CheckoutTitleCommand implements Command {

    private LibraryController libraryController;
    private Title title;

    public CheckoutTitleCommand(LibraryController libraryController, Title title) {
        this.libraryController = libraryController;
        this.title = title;

    }

    @Override
    public void execute() {
        StringBuilder sb = new StringBuilder();
        try {
            libraryController.checkoutTitle(title);
            sb.append("Thank you! Enjoy the title. \n");
        } catch (BusinessException e) {
            sb.append(e.getMessage());
        }
        System.out.println(sb.toString());
    }
}
